<template>
  <div class="rightBodyContent">
    <div class="rightBodyContent-in">
      <!--      搜索组件-->
      <!--      <SearchModle dataKey="licence" @searchFn="searchFn"></SearchModle>-->
      <!--      end-->
      <div class="mb-10">
        <div class="toplineBox">
          <div class="toplineBox-left">
            <el-button size="small" @click="gotoDetail()" type="primary">
              新增审核模版
            </el-button>
          </div>
          <p class="numberline toplineBox-right">总{{ page.total }}条</p>
        </div>
      </div>
      <!--本体列表，数据 -->
      <div class="table-body">
        <div class="table-body-box">
          <el-table
              ref="multipleTable"
              :data="arryList"
              :stripe="tableStyle.tableStripe"
              :border="tableStyle.tableBorder"
              tooltip-effect="dark"
              header-cell-class-name="table-text-c"
              style="width: 100%">
            <el-table-column
                prop="id"
                label="ID"
                align="center">
            </el-table-column>
            <el-table-column
                prop="title"
                label="审核模版名称"
                align="center">
            </el-table-column>
            <el-table-column
                align="center"
                label="操作"
                width="160">
              <template slot-scope="scope">
                <el-button plain type="primary" size="small" @click="gotoDetail(scope.row.id)">详情</el-button>
                <el-button plain type="danger" size="small" @click="deletWx(scope.row)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <!--工具条 分页-->
      <pagination
          v-show="page.total>0"
          :total="page.total"
          :page.sync="queryParams.p"
          :limit.sync="page.pagesize"
          @pagination="getList"
      />
    </div>
    <setting :visible.sync="detailVisible" :ids="ids" @getList="getList"></setting>
  </div>
</template>

<script>
import {pagination, tableoption} from '@/utils/util.js'
import setting from "./setting";
import {purchaseIndex, purchaseDelete} from "@/api/admin/purchase"

export default {
  components: {
    setting
  },
  data() {
    return {
      detailVisible: false,
      licenceId: 0,
      handleSelection: [],
      arryList: [], // 页面数据列表
      // 设置table样式
      tableStyle: tableoption,
      // 设置table页面分页所需
      page: {
        pageindex: pagination.pageIndex,
        pagesize: pagination.pageSize,
        total: pagination.total
      },
      indexOption: '',
      classesListNew: [],
      sectionList: [],
      classesList: [],
      // 搜索组件
      queryParams: {
        p: 1
      },
      parentsVisible: false,
      parentsOption: '',
      ids: 0
    }
  },
  created() {
    this.getList()
  },
  methods: {
    // 初始化
    getList() {
      purchaseIndex(this.queryParams).then(res => {
        console.log('res:', res)
        this.arryList = res.list.data
        this.page.total = res.list.total
      })
    },
    // 分页
    handleSizeChange(val) {
      this.page.pageindex = val
      this.InitFn()
    },
    // 搜索组件
    searchFn(option) {
      this.page.pageindex = 1
      this.searchForm = option
      this.InitFn()
    },
    addStudent(row) {
      this.licenceId = row || '';
      this.detailVisible = true;
    },
    deletWx(item) {
      let n = this;
      this.$confirm('确认删除【' + item.title + '】, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.closeBinding(item.id)
      }).catch(() => {
      })
    },
    closeBinding(id) {
      purchaseDelete({id: id}).then(res=>{
        if(!res.code){
          this.$message.success(res.msg)
          this.getList()
        }
      })
    },
    gotoDetail(id) {
      this.ids = id || 0
      this.detailVisible = true
    }
  },
  mounted() {
  },
}
</script>

<style scoped>

.wx-user-box-line img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  margin-right: 5px;
}

.wx-user-box-line {
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-wx {
  cursor: pointer;
  padding: 5px;
}

.btn-wx:hover {
  color: #1b8de5;
  text-decoration: underline;
}

.delet-wx {
  color: red;
  cursor: pointer;
}

.delet-wx:hover {
  text-decoration: underline;
}
</style>
